/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop"
import { NodeAttach, remember } from "@koalaui/runtime"
import { ComponentBase } from "./ComponentBase"
import { TypeChecker } from "#components"
import { ArkCommonMethodComponent } from "./ArkCommon"
import { ArkDataPanelPeer } from "./peers/ArkDataPanelPeer"
import { CommonMethod, ContentModifier } from "./ArkCommonInterfaces"
import { DataPanelAttribute, DataPanelShadowOptions, DataPanelConfiguration, DataPanelOptions } from "./ArkDataPanelInterfaces"
import { ResourceColor, Length } from "./ArkUnitsInterfaces"
import { LinearGradient } from "./ArkLinearGradientMaterialized"
/** @memo:stable */
export class ArkDataPanelComponent extends ArkCommonMethodComponent {
    getPeer(): ArkDataPanelPeer {
        return (this.peer as ArkDataPanelPeer)
    }
    /** @memo */
    public setDataPanelOptions(options: DataPanelOptions): this {
        if (this.checkPriority("setDataPanelOptions")) {
            const options_casted = options as (DataPanelOptions)
            this.getPeer()?.setDataPanelOptionsAttribute(options_casted)
            return this
        }
        return this
    }
    /** @memo */
    public closeEffect(value: boolean): this {
        if (this.checkPriority("closeEffect")) {
            const value_casted = value as (boolean)
            this.getPeer()?.closeEffectAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public valueColors(value: Array<ResourceColor | LinearGradient>): this {
        if (this.checkPriority("valueColors")) {
            const value_casted = value as (Array<ResourceColor | LinearGradient>)
            this.getPeer()?.valueColorsAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public trackBackgroundColor(value: ResourceColor): this {
        if (this.checkPriority("trackBackgroundColor")) {
            const value_casted = value as (ResourceColor)
            this.getPeer()?.trackBackgroundColorAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public strokeWidth(value: Length): this {
        if (this.checkPriority("strokeWidth")) {
            const value_casted = value as (Length)
            this.getPeer()?.strokeWidthAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public trackShadow(value: DataPanelShadowOptions): this {
        if (this.checkPriority("trackShadow")) {
            const value_casted = value as (DataPanelShadowOptions)
            this.getPeer()?.trackShadowAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public contentModifier(value: ContentModifier<object>): this {
        if (this.checkPriority("contentModifier")) {
            const value_casted = value as (ContentModifier<object>)
            this.getPeer()?.contentModifierAttribute(value_casted)
            return this
        }
        return this
    }
    public applyAttributesFinish(): void {
        // we calls this function outside of class, so need to make it public
        super.applyAttributesFinish()
    }
}

/** @memo */
export function ArkDataPanel(
  /** @memo */
  style: ((attributes: ArkDataPanelComponent) => void) | undefined,
  /** @memo */
  content_: (() => void) | undefined,
  options: DataPanelOptions
) {
    const receiver = remember(() => {
        return new ArkDataPanelComponent()
    })
    NodeAttach<ArkDataPanelPeer>((): ArkDataPanelPeer => ArkDataPanelPeer.create(receiver), (_: ArkDataPanelPeer) => {
        receiver.setDataPanelOptions(options)
        style?.(receiver)
        content_?.()
        receiver.applyAttributesFinish()
    })
}
